functions in tool and matching improved