Changed the way the cmd arguments are handled

improvement thanks to Nick Efford pointing out that the previous method
was floored.