tried to move some things from the big engine while cycle to a method