fix #1178 and #1177