collapsed some binary flags into the single loop
metadata clarity