generalized the macro