refactored to break up the user_rest.php logic across multiple files