fix background foreground switch issue