Working, not optimized, proof of concept