reimplemented as class, prepared to be used as module, and made callable from cli with arguments