fix #1143 and #1145