rewrote macro implementation