This should probably be `tx >= 0`? Additonally, `0 <= tx < xmax` is probably better.