reimplement with re module, enable cmds functions
fix infinity while loop