fixed entry function for castling cases