Inner fold step returns a value instead of writing in ref