clean and refactor the model