fix #1169 and #1170