Refactored rest api