added flag based processing