finish common function