improve resolving algorithm
merge