Thanks to Richard for providing code. Unfortunately we still didn't pass the contest again this year. Harder training! Better score!