how a mining plant works