added try catch and fixed url null problem