fix #17, fix #19, close #21