Add guards around loadng code