implemented some scaling code