refactor reg