crunched out some code, not tested