FInal working version.