refactoring and impl.