Added code to handle backbutton.