first version of the NFM algorithm...