Fix department detection