index: adding function to catch exceptions