Do some error checking.