on the way to fix issue 62 - almost done, just need to write tests + do regression testing