placeholder functions for macros to work
fix to work with macros and remove globals where possible
now works with original file and without infinite loop. cleaned up for clarity
removed a blank line for some reason