Refactored with local version