fix #595 and fix #550