Fixing an off-by-one error
Checked for the wrong SQL. Fixing