error catching logic added