Couldn't be this replaced with set arithmetics?