added level and flag tweak