Refactor model builder