buf fix for calculation boder size