changed data structures, simpler codebase, added comments