Refactored API.java