Added conditional checks for collection