implementing legal moves