Seems you are right, roles.length should be reverted to r.length...