refactor model queries