long method refactoring
final state