Fix a bug in loop modeling