Refactor Largest rectangle in histogram