create function for User model