Refactoring code

Improvement performance.