enclose work in functions
manual merge