Refactored the API