Fixed a bug in systematic errors and simplified the script.