I am facing a problem with the function loadFormData where there is check whether to pull data from the session or from the table.

```
protected function loadFormData() {
  // Check the session for previously entered form data.
  $data = JFactory::getApplication()->getUserState('com_mycomp.edit.profile.data', array());
  if (empty($data)) {
    $data = $this->getItem();
  }

  //Do further validation on $data and adjust the required values
  if (is_object($data)){
    $data->custom_field = 'custom value';
  }else if (is_array($data)){
    $data['custom_field'] = 'custom value'
  }

  return $data;
}

```

While pulling the data from session it pulls in Array format and while pulling the data from database it pulls as JObject. This makes our life harder by checking whether it is object or array. Is there any easier way to manage this by having both as JObject of Array?