added check for hierarchy