expanded try-catch for nicer code