adding upsert functionality