fixed sql error getting thrown