better scale fn implementation