performance refactor