fix intersection code