Updated to final code