changed the makeborder function slightly