fix some bugs with resection