implement callbacks for insert