Refactor code to use through2