fixed error in runCMD for while-loops