Cleaned up code with macros