Rewriting command discovery logic