added a fix to "open with", refactored