do some lamda magic to refactor out the whitelist checking code to be shared between LMS and CMS