added exception catching