refactoring or optmization?