there's probably a neater way...