lifted the regexp out of the finalize function