tidy up directory search; remove trailing whitespace