pid is being set in a more appropriate way