Refactor openurl