checkout - refactor some error handling code