refactored api controller and users controller