adding pid locking & disconnect call