move some reusable code to sharecode