Added some work logic

P.S. CMD parse moved to separate function.