Refactored rest controller