i think this is pretty well optimized. hopefully i havent missed a fundamental idea lol