Refactor APIController