that was horrendous but it works