added basic 'exception handling'