moved script core into library, so it can be called as a function
by other python programs
removed unneeded line