I posted this back in November:
Probably needs a bit of refinement now, but the principle is still the same.