refactored open file