IR sensor code simplification