use type double instead of float for scalefactor