fix #626 and #622