fix a bug in database insertion.