Solved this one by hand in the code. Cool problem.