improved gsl implementation