refactoring the part of making wire from list