Refactor optimization