fixed sql bug in getUserPrevious