macro changed into a function