fix behaviour of match
todo
test rebuilding of alts and matching