Fix return type handling for for_each