rearranging, now working on caching