test function that detect when back button is pressed