refactor returnURL method