udpated mixed model code