finished optimizing classes sql