refactor to clean up using KeyNodes classes and methods