Modified object_from_dict method to add optional object parameter