use flag in memory instead of sharedpreference