refactoring
bug fix when application become foreground.