moved common functions into headers