Refactored code for targets.