Take first department code
Did a bit of tidying up