adding triangle function