fix potential exceptions