First pass at refactoring of invoke macro