added code to capture last tab visited