long method refactor