Improved code for visualizing polygons