Optimize of generic model