clean up tri_fun