Made it parallel, did some refactoring