refactoring to clean up using KeyNodes classes and methods