fixed conditional for isLegalMove