fixed castle logic