Adding error reporting and improving chain pattern