added some jank error checking