move fns into common lib