fix loop array issue