fixed a bug in unify