added shared functions used elsewhere