fix foreach pattern