fixed bug in 1D, started on 2D