Some refactoring for clarity