refactor scripts of gathering data