refactoring code to have Segment and Powerline case class etc