fixed try catch function