hw7 refactor, added cacheing again