Made some tweeks to main method. This is very useful for my remote ssh
project