modified checkIfDepartmentinUse Function