fixed issue #589, #596