Config update with additional param and added coments for the code
rearenged code, that comman part would be in one place... also added comments to the code