make close() simpler