refactoring fragment code