fix bugs #8 and #9