Refactoring. Use fragment to handle external applications.