added upsert method