fixed bug and allowed any size of flags