Modified handleUrl method