logic for return button implemented