diff --git a/route/bgp.go b/route/bgp.go
index 0942770d2fb2c9e8f4119739d346db799ac951f0..e56b140b4bea79f00125a020c5f05b61aceb7279 100644
--- a/route/bgp.go
+++ b/route/bgp.go
@@ -2,6 +2,8 @@ package route
 
 import (
 	"fmt"
+	"strconv"
+	"strings"
 
 	"github.com/taktv6/tflow2/convert"
 )
@@ -155,11 +157,20 @@ func (b *BGPPath) Print() string {
 }
 
 func (b *BGPPath) Prepend(asn uint32, times uint16) {
+	if times == 0 {
+		return
+	}
+
+	asnStr := strconv.FormatUint(uint64(asn), 10)
+
+	path := make([]string, times+1)
 	for i := 0; uint16(i) < times; i++ {
-		b.ASPath = fmt.Sprintf("%d %s", asn, b.ASPath)
+		path[i] = asnStr
 	}
+	path[times] = b.ASPath
 
-	b.ASPathLen = b.ASPathLen + uint16(times)
+	b.ASPath = strings.TrimSuffix(strings.Join(path, " "), " ")
+	b.ASPathLen = b.ASPathLen + times
 }
 
 func (p *BGPPath) Copy() *BGPPath {