rewrite logic for InsertPass class and fix the logic when to reinfer