merged and revisited code