update to appOpened function