refactoring for RestController.php