split matchSchemas() into three functions, added IResource context