checking to make sure a value exists before indexing it