simple map function and cleanup