Bug fix with finding target of cmd function.