Optimize commit 4

Code refactoring