Refactor model plugin