diff --git a/index.html b/index.html
index 3b83d9b0909f81f86267bc3a4d7c63b40ea7c295..c3008d973299b023a9529280111c1148efa42d6e 100644
--- a/index.html
+++ b/index.html
@@ -210,7 +210,9 @@
             vec2 currentVelocity;
             if (u_scale == 1.0) currentVelocity = 1.0/u_scale*texture2D(u_velocity, fragCoord/u_textureSize).xy;
             else {
-                currentVelocity = 1.0/u_scale*bilinearInterp((fragCoord-pxCenter)*u_scale + 2.0*pxCenter, u_velocity, (u_textureSize-4.0*pxCenter)*u_scale);
+                vec2 scaledCoord = (fragCoord-pxCenter)*u_scale;
+                vec2 scaledSize = u_textureSize*u_scale;
+                currentVelocity = 1.0/u_scale*bilinearInterp(vec2(1.0, 1.0) + scaledCoord/scaledSize*(scaledSize-vec2(3.0, 3.0)), u_velocity, scaledSize);
             }
 
             //implicitly solve advection
@@ -224,7 +226,7 @@
 
             vec2 materialVal;
             //empty boundary
-            if (pos.x < 0.0 || pos.x >= u_textureSize.x || pos.y < 0.0 || pos.y >= u_textureSize.y) materialVal = vec2(0.0);
+            if (pos.x < 0.0 || pos.x >= u_textureSize.x-1.0 || pos.y < 0.0 || pos.y >= u_textureSize.y-1.0) materialVal = vec2(0.0);
             else materialVal = bilinearInterp(pos, u_material, u_textureSize);
 
             gl_FragColor = vec4(materialVal, 0, 0);