Logic fix. Next up: test cases for these.