refactoring for improving the performance.