Fixed #68

Whole code has been locked within functions which are executed at the
end of script