Moved max(forward, backward) computation part to reducer.