Code refactoring v2