diff --git a/pd/src/g_template.c b/pd/src/g_template.c
index 385a9370b2921a4d4480fb9661d6522e12d8f6a6..9766ce71e1e8b0f7edad2c2b9fa62b495a5d611a 100644
--- a/pd/src/g_template.c
+++ b/pd/src/g_template.c
@@ -3043,7 +3043,7 @@ static int draw_click(t_gobj *z, t_glist *glist,
     if (!fielddesc_getfloat(&x->x_vis, template, data, 0))
         return (0);
     int nxy = n >> 1;
-    for (i = 0, f = x->x_vec; i < n; i++, f += 2)
+    for (i = 0, f = x->x_vec; i < nxy; i++, f += 2)
     {
         t_float xval = fielddesc_getcoord(f, template, data, 0);
         t_float yval = fielddesc_getcoord(f+1, template, data, 0);