Refactor to fragment