   on the balance of the associated account and is dependant on the action
   (debit or credit) and the account type (asset, liability, equity,
   income, or expense)"
-  [storage transaction]
-  (update-in transaction
-             [:items]
-             #(map (partial add-item-balance-and-index
-                            storage
-                            (:transaction-date transaction))
-                   %)))
+  [storage transaction-date items]
+  (->> items
+       (group-by :account-id)
+       (mapcat (partial add-item-balance-and-index
+                     storage
+                     transaction-date))))
 
 (defn- subsequent-items
   "Returns items in the same account with an equal or greater

  "Updates the accounts affected by the specified transaction items"
  [storage-spec items]
  (doseq [[account-id items] (group-by :account-id items)]
    (let [last-item (->> items
                         (sort-by #(- 0 (:index %)))
                         first)
          subsequent-items (subsequent-items storage-spec last-item)
          final (reduce (fn [{:keys [index balance]} item]
                          (let [new-index (+ 1 index)

    (if (validation/has-error? validated)
      validated
      (let [storage (storage storage-spec)
            items-with-balances (calculate-balances-and-indexes storage
                                                                (:transaction-date validated)
                                                                (:items validated))
            _ (update-affected-balances storage-spec items-with-balances)
            result (create-transaction storage (before-save (assoc validated :items items-with-balances)))
            items (into [] (map #(->> (assoc % :transaction-id (:id result))
                                      before-save-item
                                      (create-transaction-item storage)
                                      prepare-item-for-return)
                                items-with-balances))]
        (assoc result :items items)))))

(defn find-by-id
