First functional (but imcomplete) version