changes to sub-sample routine