Using better condensed code for dirname