replace $.each by for