added limit to number of flags