added check for nested blocks