Transfered the code to model