     date.push(key)
     # build the multi dimensional CPUs array
     $forEach cpusIndexes, (value, key) ->
-      cpus[value].push(n.v[cpusIndexes[value]]*100)
+      cpus[key] ?= []
+      cpus[key].push(n.v[value]*100)
 
     return
 
-  result.memoryFree = memoryFree
-  result.memoryUsed = memoryUsed
-  result.memory = memory
-  result.date = date
-  result.cpus = cpus
-
-  return result
+  # the final object
+  return {
+    memoryFree: memoryFree
+    memoryUsed: memoryUsed
+    memory: memory
+    date: date
+    cpus: cpus
+  }
 
 stats.params = {
   id: { type: 'string' }

  # CPU: fetch every CPUs!
  cpusIndexes = []
  index = 0
  current_cpu = 'cpu'+index
  while $findIndex(json.rrd.ds, 'name': current_cpu) isnt -1
    cpusIndexes.push(index)
    index++
    current_cpu = 'cpu'+index

  memoryFreeIndex = $findIndex(json.rrd.ds, 'name': 'memory_internal_free')
  memoryIndex = $findIndex(json.rrd.ds, 'name': 'memory')

  memoryUsed = []
  memory = []
  cpus = []
  date = [] #TODO
  # TODO: fetch other info: network, IOPS etc.


  $forEach json.rrd.rra[0].database.row, (n, key) ->
    # WARNING! memoryFree is in Kb not in b, memory is in b
