Nested if to ensure both sensors could activate