nextUrl function fixes