Replace a duplicate code with macros.