revert optimization change

this is too big a refactoring and should do in its own pull request