fixed pointer arithmetic that caused crashing on Windows