replaced assertions with the helper function.