Huge runtime improvement but still pretty naive