Working version of KF using RandomSearch