Fix APP_EXISTS check