replaced macros with functions