all tests pass but this is ugly as heck