fixing O(n^2) issue with inport