add a function too
merged version