modified to fit new config structures.
fixed bug: always updating