added exception handeling