flash on registering works properly after refactoring