Modify if statement for switching gpio.