Move dig function into external module