refactor code to open a new tab