Added a nearest neighbour scaling function