fix array_element so we dont index into array past array length