using database to refactor chapter2 start