refactor the logic for InsertPass