Now improved with code that actually works