move directory reading into module in advance of making it side effect free