updatin segmentation code and adding test script