Split run method

Code of commands moved from run method to separate methods.