Converted to recursively using fragments rather than activities.