added a function to toggle flags