moved try catch block to constructor