Bug fix with flags