Fixing the command loop