A bit clunky but working