changed os.isdir to os.path.isdir