We study higher derivative terms associated with scalar field cosmology. We consider a coupling between the scalar field and the geometry inspired by the Pais-Uhlenbeck oscillator, given by $alphapartial_{mu}partial^{mu}phipartial_{ u}partial^{ u}phi.$ We investigate the cosmological dynamics in a phase space. For $alpha>0$, we provide conditions for the stability of de Sitter solutions. In this case the crossing of the phantom divide $w_{DE}=-1$ occurs once; thereafter, the equation of state parameter remains under this line, asymptotically reaching towards the de Sitter solution from below. For $alpha<0,$ which is the portion of the parameter space where in addition to crossing the phantom divide, cyclic behavior is possible, we present regions in the parameter space where, according to Smilgas classification the ghost has benign or malicious behavior.