fix that all equalities were reversed in head and tail