refactor
use flag
refactor