added erorr handler