Updated array_to_function error handling.