got rid of macros and switched to templates