tightening up implementaiton, adding testing