Modified closing logic