Prevention is better than cure: targeted vaccination to halt epidemics