refactored fragment code and xml code for gragment view