Refactor to remove mark temp variable