first R file: common functions