export castles logic