factored code into using fragments