added rescale and categorize function