fixed issue #234, #235 and #236