added some pointer arithmetic optimizations but not stable yet so not