naive implementation of template matching done