Can we avoid this long if-else? You could have a map <cmd, function> ideally.