try catch was on wrong place