Refine perform algorithm & Bug fix