fix #8 fix #7 fix #21