functional version. added customizations.