algorithm step 2 in working state with “hotfixes” #vaguecommitmessages