Wrapped kNN implementation in methods and made it more generic