refactor the creation of the cmdline to a seperate function