better triangle calculation