added requirement for maxK