Modified the new $manage logic to wrap $agent and $server code in the if statement