fix bugs #29 30 32