use flag to prevent bugs