Explanation to the resistance anomaly observed in nanowires