refactor into macro expansion