Tried to add code for sequential and parallel: haven't tested, probably full of bugs