fix bug in refine()