made the script a little bit more robust against slightly corrupted data