match directive refactor