Refactor register