Some code refactoring have been applied