add generic function for applying limits to datasets. need to move this to a library