Improveerrorhandling

this is what was missing from the previous PR and with new error handling...