fix #1128 and #1124