refactor main and model file