refactor register