Ok thanks i also read this article:
en.wikipedia.org/wiki/Rules_of_chess Castling consists of moving the king two squares towards a rook, then placing the rook on the other side of the king, adjacent to it.[2] Castling is only permissible if all of the following conditions hold:
The king and rook involved in castling must not have previously moved;
There must be no pieces between the king and the rook;
The king may not currently be in check, nor may the king pass through or end up in a square that is under attack by an enemy piece (though the rook is permitted to be under attack and to pass over an attacked square);
The king and the rook must be on the same rank (Schiller 2003:19).