changed the inserting into db routine