fixed bug related to castling