Refactored open code