cleaned up the findShapes function