Modified query function to return only local URLs