Edited format to "modulize" it

Now allows one to call it as a module and use it in own script or run
from the command line.