moved query handling to collection