This is pretty ugly...