Changed macro to function