add case of reversed key/value in foreach