refactoring + testing