avoiding duplicate terminals