Refactor, do not pass flow explictly