Fixing incorrect index for prepared statements