Added additional checks and URL fetching