expanded the error catching block