Use array_filter to get rid of nulls in buildUrl function.