split the didBeginContact function