added check for sortItems