created GC counting func for a generic segment
minor code modifications