trying to answer issue 56. not finished yet.
merged