refactor and update model and test