moved math part to an R script, much simpler