Added segment touch check code