it isn't that complicated.  could be improved further.