add try catch handling for errors