fixed #1065 and #1069