add commit for database writing.