moved ksHelper functions