Refactored the code to analyze the variables range of the method call.