The solution works but isn't pretty.