added old branch, rewritten some matching