cleanup code
use macros for variable loop usage flag