added logic for switching game pieces