added logic for alternating turns