add option to run command and fix things

I just added run command option and fixed a few things to make it stable.