Modified database query for insertion