bulk of code done, not tested yet