change to scaling method and tidy up

changed scaling for simpler method and cleaned code abit