extracted common functions