Optimize upsert account method