Refactoring safe_source