Added exitOnError method