Still a bit silly but seems to work