replace code to use model.query or session.query(model) with helpers.session_query function