Added code to detect intersects