Fix some unclear variable names:
  $result -> $histories
  $element -> $history
  $data_array -> $hglHistories
  $data -> $hglHistory