fix bug in simplification algorithm