refactored register controller