added castling code (untested)