Fixed: even if directory path contains spaces , it will take full path
optimized code