hw-2: updated script to handle threads/processes