refine the bug fixing code