initial flag calculation added