Adding try-catch and moving depedencies