added check for required flag