Finally fixes the primary key error as well as insertorupdate