avoid using subprocesses in jobs segment

Avoiding subprocess calls makes the code more efficient.