fixed query algorithm and styles