Refactor register controller