updated to use more functionality from common.R