Fixed some bug in error estimation