works. code somewhat cleaned up too. next step is moving the lib to a better place/name.