edited code: declared int i