updated user authenticate function