added login function and user model