Copied over the 'Prepare' function