Refactor into APIController