Add triangle function
remove unused code