move functions out of ks.ready()