resolved a bug with castling