refactoring made necessary by growth of the code