Refactor target.c