move some code around before refactoring.