created a common function