added more segment functions, implemented map