Fix finalUrl not defined error