Changes for CodeCoverage & Refactor of Algorithm