Optimization of merge function
Rewrote import function to use regex