Modified getFirstFocusable function to return correct first focusable element