changing kernel writer to handle 2d loops