Completed defensive programming sample