made a very ugly auto-scale function