Moved 1dopt swr code to function in seperate file