segments array refatctored for issue #2; some warnings resolved