Improve an example code of applicationDidEnterBackground