improved safety by adding set flags