#300 move query to model scope

#300 Solved.