faster loop using index