this error handling is foolish (breaks PEP-8) but is good enough for my purposes at the moment.