Messy, but works.