Refactor back into a single function to register