bug fix
Test: works for small data only