Works for small datasets but not large ones