more sane version of the extract code for shapefiles