fixed some bugs related with isLegalMove