check array elements are set before returning their values