Refactor code and add docstring. Add a feature to save the computed information into an SQLite database.