Creating the model function