Get rid of macros and do these calculations only once instead