Finished logic for macro management - fine tuning remains