refactoring & testing