fixing exeption andling