modified triangle to use each_cons