code for ship border refactored