refactoring
first attempt