allowing $dirname to be an array