refactored register