This is the bit I've been trying to do myself.