added condition to check pid before starting