changing string contruction way

Old string append is unefficient way of contructing a command line, I changed it to use string's join method.