fix #defect31 and completed #story89