added a fix when creating remote directories, only the required directories are created