adding scaling code: yet to be compiled