rewritten the storage code