Refactored blocks algorithm