Optimize the method LaunchApplication and CloseApplication