Changed it to use flags instead of stats