Hamlin edged Martin Truex Jr. for a record-setting win