move code from activity to fragment