Code working in 2d! (but it's very slow...)