added try and except for errors