Some code refactor