refactor scaling stuff