miny and maxx are inverted here!