Replace const double& with double (makes code simpler and not slower)