Do some error trapping