check exists before returning

check that array exists before returning its value to avoid error when
it doesnt exist