some memoization, but should be saving to file