CalculateFlags now working