added exceptoin handling