renamed root state to $root (which then acts as a reserved name)