fixed sql from prev commit