erro handling improved