refactored borderImage function
update for r20193