refactor/clean code and fix duplicate registration