refactored code and moved code to the model