bug fix

Fixed a bug that caused Application to leave foreground