fixed bug discovered by RaptorChess