added better handling for trying to retrieve values from non-objects