complex method refactoring