factored out drawing of segments. helps with issue #23