updated determine_command method