refactor and add recursive directory reading abilities