code refactoring v2