fix undefined $i