added some sort of cache, needs refactoring