fix bug - i not defined