Fixing do_command function