Fix the problem in Error function