fixing loop in model