Better working version, adding a target counter to avoid duplicate targets. Built off
work by Evan Bollig.