re-write and clean up of code. now as a class with settings that can be changed