finalized output code