it works-ish.. needs error checking