Working and tested version.