Fixed bugs
Some optimizing query