Converting triangle format