moved common functions