changed to use common function