fixed minor bug when adding terms