implement finish additions to code - taken from SQLite version