reformatted endContact to reduce code duplication