Refactored the whole REST API