refactored user.php and user_model.php