changed memory allocation to segments