Proper error handling implementation