Move subcommand recognition to separate method