Adding check to cleanup procedure