trying to get KS function to work