Try out some C macros to reduce duplicated code