generalized scale_amp, cleaned up code for readability
resolved merge conflict