changes due to minor comments which led to major refactoring. most tests pass