replaced assertions with perrors