partially added ray trace code