updated sub-sample routine