Code okay, not tested.