fixing exeption handling