Added exception handling to IsMoveInputLegal