Added exception catching