Changed how command is generated to be passed to subprocess call