Fix error hanlding