adding method that check if activity is closed or opened