added basic exception handling