minor adjustments, added assert