added comments to shape detection code