fixed bug on checking legal move