catch exceptions to avoid crashes