Final implementation in serial
Parallel version working