refactoring matchl function
simplify functions to macro