updated server code for app switching