added castling and knight logic