Avoid duplicated code to get the target method index