Add some error checking