intersection code. untested