fixing some undefined errors
try catch