adds conditions for connectedness, cleans up controller