added check for keys before filtering subjects