Changed $id to $i