writing most of what I need here, now to code it up