added switch homing detection