rewrote the top level script as a class