database insertion fully implemented