Refine and bug fix