move common pkg to function