getting insert to handle nonsubkey case
cleaning up sql for insert