Added a error hundling.