Updates code to be a little more resilient