moved common functions to modules