re factored shared code