Refactored algorithms