updated to handle external urls