changed math macros to functions for type safety