Fixed util function for finding directories.