Adding Error checking in example