Created static reduce method and added synchronized block to map and reduce