added checkLegalMove