Project 3 code, can be parallelized and rewrite in C