added file qgen.func.R