refactor triangle, complete about iteration