revised code

many methods of segment class moved to world class for simplification