fixed bug in move legality code