messy, but working