moved triangle code into its own class