worked from #3, with additions