Move temp variables back into function body