write defensive code