Made some more changes to the scaling...

changed the function so that it is not recursive.