 
     @skip += members.length
 
-    for member in members
-      member.loggedInUserRoles = loggedInUserRoles # FIXME
-      @listController.addItem member
+    @fetchUserRoles members, (members) =>
+      for member in members
+        member.loggedInUserRoles = @loggedInUserRoles # FIXME
+        @listController.addItem member
 
     @listController.lazyLoader.hide()
     @searchContainer.show()

    kd.warn err


  listMembers: (members, loggedInUserRoles) ->

    unless members.length
      @listController.lazyLoader.hide()


      return @handleError err  if err

      @fetchUserRoles members, (members) =>
        @listMembers members
        @isFetching = no


  fetchUserRoles: (members, callback) ->

    # collect account ids to fetch user roles
    ids = members.map (member) -> return member.getId()

    myAccountId = whoami().getId()
    ids.push myAccountId

    @getData().fetchUserRoles ids, (err, roles) =>
      return @handleError err  if err

      # create account id and roles map
      userRoles = {}

      # roles array is a flat array which means when you query for an account
      # the response would be 3 items array which contains different roles for
      # the same user. create an array by user and collect all roles belong
      # to that user.
      for role in roles
        list = userRoles[role.targetId] or= []
        list.push role.as

      # save user role array into jAccount as jAccount.role
      for member in members
        roles = userRoles[member.getId()]
        member.roles = roles  if roles

      @loggedInUserRoles = userRoles[myAccountId]

      callback members


  handleError: (err) ->
