refactoring out complexity