swapped error handling