Less hacky solution

(but still not the one I wanted)