Completed defensive coding sample.