fixed registration, refactoring