improved the error diagnosis