added triangle calculation