fix #1021 #1012