def METHOD_NAME(flow):
    """
    Makes it so every Finished task in the flow stores its result in a prefect.RESULTS dict
    """
    def state_handler(task, old_state, new_state):
        if new_state.is_finished():
            map_index = prefect.context.get("map_index")
            if map_index is None:
                map_index = -1
            prefect.RESULTS[(task.slug, map_index)] = new_state.result
        return new_state
    for task in flow.tasks:
        task.state_handlers.append(state_handler)