Moved 1d pipe code into seperate function
Moved 2d opt swr code into seperate function