Redesign question query algorithm