new model code rewritten