first attempt at more generic select top-k