Fixed error where all the paste were the same due to the temp object declaration being outside the try block