added cache to the SEC algorithm