near final code